import http from '@/http/http'
import { AddRoleModel, AssignSaveParams, AssignTreeParams, DeleteRoleModel, RoleListParam } from './roleModel'

enum Api {
    getList = '/api/role/list',
    add = '/api/role',
    edit = '/api/role',
    delete = '/api/role',
    assignTree = '/api/role/getAssignPermissionTree',
    assignSave = '/api/role/roleAssignSave'
}

// 角色列表
export const getRoleListApi = async (params:RoleListParam) => {
    return await http.get(Api.getList, params)
}

// 新增角色
export const addRoleApi = async (params:AddRoleModel) => {
    return await http.post(Api.add, params)
}

// 编辑角色
export const editRoleApi = async (params:AddRoleModel) => {
    return await http.put(Api.edit, params)
}

// 删除角色
export const deleteRoleApi = async (id:DeleteRoleModel) => {
    return await http.delete(Api.delete, id)
}

// 分配权限树的数据
export const assignTreeApi = async (params:AssignTreeParams) => {
    return await http.get(Api.assignTree, params)
}

// 分配权限保存
export const assignSaveApi = async (params:AssignSaveParams) => {
    return await http.post(Api.assignSave, params)
}
